import 'package:blurb/common/routers/names.dart';
import 'package:blurb/pages/community/community.dart';
import 'package:blurb/pages/community/sharing.dart';
import 'package:blurb/pages/community/sharing_detail.dart';
import 'package:blurb/pages/community/sharing_publish.dart';
import 'package:blurb/pages/community/topic.dart';
import 'package:blurb/pages/community/topic_detail.dart';
import 'package:blurb/pages/community/topic_publish.dart';
import 'package:blurb/pages/home/home.dart';
import 'package:blurb/pages/login/login.dart';
import 'package:blurb/pages/login/guide.dart';
import 'package:blurb/pages/login/register.dart';
import 'package:blurb/pages/main.dart';
import 'package:blurb/pages/message/message.dart';
import 'package:blurb/pages/personal/information.dart';
import 'package:blurb/pages/personal/personal.dart';
import 'package:blurb/pages/personal/settings.dart';
import 'package:blurb/pages/splash.dart';
import 'package:go_router/go_router.dart';

class RPS {
  static final routers = GoRouter(
    initialLocation: RNS.splash, // 添加初始路由位置
    routes: [
      // 启动页
      GoRoute(
        path: RNS.splash,
        builder: (context, state) => const SplashPage(),
      ),
      // // 引导页
      // GoRoute(
      //   path: RoutersNames.guide,
      //   builder: (context, state) => const GuidePage(),
      // ),
      // 登录页
      GoRoute(
        path: RNS.login,
        builder: (context, state) => const LoginPage(),
      ),
      // 登录引导页
      GoRoute(
        path: RNS.guide,
        builder: (context, state) => const LoginGuidePage(),
      ),
      // 注册页
      GoRoute(
        path: RNS.register,
        builder: (context, state) => const RegisterPage(),
      ),
      // 主页
      GoRoute(
        path: RNS.main,
        builder: (context, state) => const MainPage(),
      ),
      // 首页
      GoRoute(
        path: RNS.home,
        builder: (context, state) => const HomePage(),
      ),
      // 社区页
      GoRoute(
        path: RNS.community,
        builder: (context, state) => const CommunityPage(),
      ),
      // 分享页
      GoRoute(
        path: RNS.sharing,
        builder: (context, state) => const SharingPage(),
      ),
      // 分享详情页
      GoRoute(
        path: RNS.sharingDetail,
        builder: (context, state) {
          final String? idStr = state.uri.queryParameters['id'];
          final int id = idStr != null ? int.parse(idStr) : 1;
          return SharingDetailPage(shareId: id);
        },
      ),
      // 分享发布页
      GoRoute(
        path: RNS.sharingPublish,
        builder: (context, state) => const SharingPublishPage(),
      ),
      // 话题页
      GoRoute(
        path: RNS.topic,
        builder: (context, state) => const TopicPage(),
      ),
      // 话题详情页
      GoRoute(
        path: RNS.topicDetail,
        builder: (context, state) {
          final String? idStr = state.uri.queryParameters['id'];
          final int id = idStr != null ? int.parse(idStr) : 1;
          return TopicDetailPage(topicId: id);
        },
      ),
      // 话题发布页
      GoRoute(
        path: RNS.topicPublish,
        builder: (context, state) => const TopicPublishPage(),
      ),
      // 消息页
      GoRoute(
        path: RNS.message,
        builder: (context, state) => const MessagePage(),
      ),
      // 个人页
      GoRoute(
        path: RNS.personal,
        builder: (context, state) => const PersonalPage(),
      ),
      // 设置页
      GoRoute(
        path: RNS.settings,
        builder: (context, state) => const SettingsPage(),
      ),
      // 信息页
      GoRoute(
        path: RNS.information,
        builder: (context, state) => const InformationPage(),
      ),
    ],
  );
}